package com.ch.engine.statemachine.builder;

import com.ch.engine.statemachine.enums.Event;
import com.ch.engine.statemachine.enums.State;
import com.ch.engine.statemachine.handler.IStateHandler;
import com.ch.engine.statemachine.pojo.SopProcess;

/**
 * 过程建造者
 */
public class SopProcessBuilder {

    private SopProcess sopProcess;

    private void setSopProcess(SopProcess sopProcess) {
        this.sopProcess = sopProcess;
    }

    public static SopProcessBuilder getInstance() {
        SopProcessBuilder sopProcessBuilder = new SopProcessBuilder();
        sopProcessBuilder.setSopProcess(new SopProcess());
        return sopProcessBuilder;
    }

    public SopProcessBuilder from(State state) {
        sopProcess.setFrom(state);
        return this;
    }

    public SopProcessBuilder to(State state) {
        sopProcess.setTo(state);
        return this;
    }

    public SopProcessBuilder event(Event event) {
        sopProcess.setEvent(event);
        return this;
    }

    public SopProcessBuilder handler(IStateHandler handler) {
        sopProcess.setHandler(handler);
        return this;
    }

    public SopProcess build() {
        return sopProcess;
    }
}
